/**
 * TestBuilder.java
 */
package com;

import com.module.builder.ComputerBuilder;
import com.module.builder.HPComputerBuilder;
import com.module.builder.LenoveComputerBuilder;
import com.module.computer.Computer;

/**
 * @author Administrator
 * http://www.cnblogs.com/Terrylee/archive/2005/12/19/299878.html
 * 有时候面临着“一个复杂对象”的创建工作，其通常由各个部分的子对象用一定的算法构成
 * 
 */
public class TestBuilder {
 
	public static void main(String[] args) { 
		//模式1 (有Director)
        Computer lenoveComputer,hpComputer;    
        ComputerBuilder lenoveComputerBuilder = new LenoveComputerBuilder();    
        ComputerBuilder hpComputerBuilder     = new HPComputerBuilder();    
        Director director;    
        director = new Director(lenoveComputerBuilder);    
        lenoveComputer=director.getComputer();    
        director = new Director(hpComputerBuilder);    
        hpComputer=director.getComputer();    
        System.out.println("lenoveComputer is made by:"+lenoveComputer.getCpu()+lenoveComputer.getMemory()+lenoveComputer.getMainboard());    
        System.out.println("hpComputer is made by:"+hpComputer.getCpu()+hpComputer.getMemory()+hpComputer.getMainboard());    
    // 模式2 (无需 Director )
        lenoveComputer=lenoveComputerBuilder.getComputer();
        hpComputer = hpComputerBuilder.getComputer();
        System.out.println("lenoveComputer is made by:"+lenoveComputer.getCpu()+lenoveComputer.getMemory()+lenoveComputer.getMainboard());    
        System.out.println("hpComputer is made by:"+hpComputer.getCpu()+hpComputer.getMemory()+hpComputer.getMainboard());    
	
	}  
	
	
 
}
